package com.example.wly.application_3_homework;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {

TextView tvInfo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Button btnBackground=(Button)findViewById(R.id.btn_background);
         tvInfo=(TextView)findViewById(R.id.tv_info);
        btnBackground.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(Main2Activity.this,ColorActivity.class);
                startActivityForResult(intent,1);
            }
        });

    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
       int colorValue= data.getIntExtra("color",0);
        tvInfo.setBackgroundColor(colorValue);
    }
}
